import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;


public class Accueil extends Composite {

	private static Text txtMail;
	private static Text textMdp;
	private static Text txtPhotonumVousPropose;
	
	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public Accueil(final Composite parent, int style) {
		super(parent, style);
		
		Group grpConnection = new Group(this, SWT.NONE);
		grpConnection.setText("Connection");
		grpConnection.setBounds(24, 10, 318, 96);
		
		txtMail = new Text(grpConnection, SWT.BORDER);
		txtMail.setText("Mail");
		txtMail.setBounds(10, 25, 128, 21);
		
		textMdp = new Text(grpConnection, SWT.BORDER);
		textMdp.setText("*******");
		textMdp.setBounds(144, 25, 128, 21);
		
		Button btnLogin = new Button(grpConnection, SWT.NONE);
		btnLogin.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				
				parent.dispose();
				
				try {
					Display display = Display.getDefault();
					InterfaceClient shell = new InterfaceClient(display);
					shell.open();
					shell.layout();
					while (!shell.isDisposed()) {
						if (!display.readAndDispatch()) {
							display.sleep();
						}
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				
			}
		});
		btnLogin.setBounds(233, 61, 75, 25);
		btnLogin.setText("Login");
		
		Button btnQuitter = new Button(grpConnection, SWT.NONE);
		btnQuitter.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				
				parent.dispose();
			}
		});
		btnQuitter.setBounds(10, 61, 75, 25);
		btnQuitter.setText("Quitter ");
		
		Group grpCompte = new Group(this, SWT.NONE);
		grpCompte.setText("Compte");
		grpCompte.setBounds(357, 10, 285, 96);
		
		Label lblToujoursPasDe = new Label(grpCompte, SWT.NONE);
		lblToujoursPasDe.setBounds(23, 27, 180, 15);
		lblToujoursPasDe.setText("Toujours pas de compte ?");
		
		Button btnCreationDunCompte = new Button(grpCompte, SWT.NONE);
		btnCreationDunCompte.setBounds(133, 61, 130, 25);
		btnCreationDunCompte.setText("Création d'un Compte");
		
		Label lblNewLabel = new Label(this, SWT.NONE);
		String chemin =  getClass().getResource("Logo.png").toString(); 
		chemin = chemin.substring(6);
		
		Image image = new Image(parent.getDisplay(), chemin) ;
		lblNewLabel.setImage(image);
		lblNewLabel.setBounds(24, 104, 318, 263);
		
		Group grpVisualisation = new Group(this, SWT.NONE);
		grpVisualisation.setText("Visualisation");
		grpVisualisation.setBounds(357, 115, 285, 235);
		
		Button btnVoirLesAlbumslivres = new Button(grpVisualisation, SWT.NONE);
		btnVoirLesAlbumslivres.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				
				try {
					Display display = Display.getDefault();
					VisualiseAlbum shell = new VisualiseAlbum(display,1);
					shell.open();
					shell.layout();
					while (!shell.isDisposed()) {
						if (!display.readAndDispatch()) {
							display.sleep();
						}
					}
				} catch (Exception e1) {
					e1.printStackTrace();
			}
				
			}
		});
		btnVoirLesAlbumslivres.setBounds(60, 167, 167, 25);
		btnVoirLesAlbumslivres.setText("Voir les Albums publics");
		
		txtPhotonumVousPropose = new Text(grpVisualisation, SWT.BORDER | SWT.CENTER | SWT.MULTI);
		txtPhotonumVousPropose.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
		txtPhotonumVousPropose.setText("PhotoNum vous propose de voir\r\nles albums et livres publics mise à disposition\r\npar nos clients.\r\n\r\n\r\nAccedez à une atmosphère Unique !\r\n\r\n\r\n         ");
		txtPhotonumVousPropose.setBounds(10, 29, 265, 132);
		
		Button btnVoirLesLivres = new Button(grpVisualisation, SWT.NONE);
		btnVoirLesLivres.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				
				try {
					Display display = Display.getDefault();
					VisualiseLivre shell = new VisualiseLivre(display,1);
					shell.open();
					shell.layout();
					while (!shell.isDisposed()) {
						if (!display.readAndDispatch()) {
							display.sleep();
						}
					}
				} catch (Exception e1) {
					e1.printStackTrace();
			}
				
				
			}
		});
		btnVoirLesLivres.setBounds(60, 198, 167, 25);
		btnVoirLesLivres.setText("Voir les Livres publics");

	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
		
		
	}

}
